From ebcb37da0c665e5f997257b365d40357b2fac31c Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Mon, 19 Mar 2007 11:09:57 +0000 Subject: [PATCH] Fix memory size handling. These were by Tom Wilkie , and were dropped accidentally by me when merging. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendDomainInfo.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 78a97b3c45..da3e5936a3 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -576,12 +576,14 @@ class XendDomainInfo: if target <= 0: raise XendError('Invalid memory size') - self.info['memory_static_min'] = target * 1024 * 1024 + MiB = 1024 * 1024 + self.info['memory_dynamic_min'] = target * MiB + self.info['memory_dynamic_max'] = target * MiB + if self.domid >= 0: self.storeVm("memory", target) self.storeDom("memory/target", target << 10) else: - self.info['memory_dynamic_min'] = target xen.xend.XendDomain.instance().managed_config_save(self) def setMemoryMaximum(self, limit): @@ -981,7 +983,7 @@ class XendDomainInfo: def getMemoryTarget(self): """Get this domain's target memory size, in KB.""" - return self.info['memory_static_min'] / 1024 + return self.info['memory_dynamic_max'] / 1024 def getMemoryMaximum(self): """Get this domain's maximum memory size, in KB.""" @@ -1470,7 +1472,7 @@ class XendDomainInfo: # values. maxmem, memory, and shadow are all in KiB. # but memory_static_max etc are all stored in bytes now. memory = self.image.getRequiredAvailableMemory( - self.info['memory_static_min'] / 1024) + self.info['memory_dynamic_max'] / 1024) maxmem = self.image.getRequiredAvailableMemory( self.info['memory_static_max'] / 1024) shadow = self.image.getRequiredShadowMemory( @@ -2018,7 +2020,11 @@ class XendDomainInfo: info = dom_get(self.domid) if not info: return - + + if info["maxmem_kb"] < 0: + info["maxmem_kb"] = XendNode.instance() \ + .physinfo_dict()['total_memory'] * 1024 + #manually update ssidref / security fields if security.on() and info.has_key('ssidref'): if (info['ssidref'] != 0) and self.info.has_key('security'): @@ -2402,7 +2408,7 @@ class XendDomainInfo: def __str__(self): return '' % \ (str(self.domid), self.info['name_label'], - str(self.info['memory_static_min']), DOM_STATES[self.state]) + str(self.info['memory_dynamic_max']), DOM_STATES[self.state]) __repr__ = __str__ -- 2.30.2